<?php
/**
*
*/
namespace comm\widgets;

use ulue\ext\zui;
use ulue\core\router;

class MyNavbar extends zui\Navbar
{
    public function beginExecute()
    {
        $this->navHeader['brand']['text'] = ' BLOG ';

        return parent::beginExecute();
    }

    public function mainNav()
    {
        return [

            'post/index'    => [
                'text'  => ' 首页',
                'href'  => \Ioc::get('app.uri')->get('index.path'),
                'icon'  => 'icon-home',
                'attrs' => [],
            ],

            'site/client'    => [
                'text'  => ' 前端',
                'href'  => '' ,
                'icon'  => 'icon-list',
                // 'attrs' => [],
                'submenu' => [
                    'site/list' => [
                        'text'  => ' Html/css',
                        'href'  => router\Uri::to('site/list') ,
                        'icon'  => 'icon-th',
                    ],
                    'site/add' => [
                        'text'  => ' Javascript',
                        'href'  => router\Uri::to('site/add') ,
                        'icon'  => 'icon-plus',
                    ],
                ],
            ],
            'site/server'    => [
                'text'  => ' 后端',
                'href'  => '' ,
                'icon'  => 'icon-list',
                // 'attrs' => [],
                'submenu' => [
                    'category/php' => [
                        'text'  => 'PHP',
                        'href'  => router\Uri::to('site/list') ,
                        'icon'  => 'icon-th',
                    ],
                    'category/python' => [
                        'text'  => 'Python',
                        'href'  => router\Uri::to('site/list') ,
                        'icon'  => 'icon-th',
                    ],
                    'category/c-lang' => [
                        'text'  => 'C/C++',
                        'href'  => router\Uri::to('site/add') ,
                        'icon'  => 'icon-plus',
                    ],
                ],
            ],
            'site/linux'    => [
                'text'  => ' Linux',
                'href'  => '' ,
                'icon'  => 'icon-list',
                // 'attrs' => [],
                'submenu' => [
                    'category/php' => [
                        'text'  => 'Shell',
                        'href'  => router\Uri::to('site/list') ,
                        'icon'  => 'icon-list',
                    ],
                    'category/python' => [
                        'text'  => '使用',
                        'href'  => router\Uri::to('site/list') ,
                        'icon'  => 'icon-list',
                    ]
                ],
            ],
            'site/about'=> ['text' => ' 关于', 'href' => router\Uri::to('site/about') , 'icon' => 'icon-chat' ],
        ];
    }

    /**
     * 右侧导航
     * 配置数据跟 mainNav() 一样
     */
    protected function rightNav()
    {
        //  setting
        $rightNav = [
            '--index'    => [
                'text'  => ' 链接',
                'href'  => \Ioc::get('app.uri')->get('index.path'),
                'icon'  => 'icon-external-link',
                'attrs' => [],
                'submenu' => [
                    [
                        'text'  => 'GIT',
                        'href'  => 'http://www.higit.com/',
                        'icon'  => 'icon-branch',
                        'attrs'  => ['target'=>'_blank'],
                    ],
                    [
                        'text'  => 'FileManager',
                        'href'  => 'http://www.kode.com/',
                        'icon'  => 'icon-archive',
                        'attrs'  => ['target'=>'_blank'],
                    ],
                ],
            ]
        ];

        if (\Ulue::$app->user->isLogin) {

            $rightNav['site/more'] = [
                'text'  => ' hi! <strong>' . \Ulue::$app->user->name . '</strong>',
                'href'  => '' ,
                'icon'  => 'icon-user',
                // 'attrs' => [],
                'submenu' => [
                    [
                        'text'  => '设置',
                        'href'  => '',
                        'icon'  => 'icon-cog',
                    ],
                    [
                        'text'  => ' 退出',
                        'href'  => '/site/logout',
                        'icon'  => 'icon-signout',
                    ],
                ],
            ];
        } else {
            $rightNav['site/login'] = ['text' => ' 登录', 'href' => router\Uri::to('site/login') , 'icon' => 'icon-signin' ];
        }

        return $rightNav;
    }

}// end class MyNavbar